<!-- 我的应用 -->
<template>
    <s-card>
        <template v-slot:title>我的应用</template>
        <template v-slot:more>更多</template>
        <template v-slot:content>
            <div class="my-app">
                <div
                    class="item"
                    @click="toApp(item)"
                    v-for="item in appList"
                    :key="item.id"
                >
                    <div
                        class="left"
                        :style="{
                            background: item?.logo?.color,
                        }"
                    >
                        <i class="iconfont" :class="item?.logo?.icon"></i>
                    </div>
                    <div class="right">
                        <div :title="item.name" class="title">
                            {{ item.name }}
                        </div>
                        <p>政务</p>
                    </div>
                    <div
                        class="status"
                        :class="item.status == '已发布' ? 'success' : 'info'"
                    >
                        {{ item.status }}
                    </div>
                </div>
            </div>
        </template>
    </s-card>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { AppVO } from '@/api/app/types.ts'
import SCard from '@/components/SCard/index.vue'
const appList = ref<AppVO[]>([
    {
        id: '1',
        name: '物流系统',
        status: '未发布',
        logo: {
            color: '#317FFF',
        },
    },
    {
        id: '1',
        name: '物流系统',
        status: '已发布',
        logo: {
            color: '#ff6731',
        },
    },
    {
        id: '1',
        name: '物流系统物流系统物流系统物流系统物流系统物流系统物流系统物流系统',
        status: '已发布',
        logo: {
            color: '#0ec547',
        },
    },
    {
        id: '1',
        name: '物流系统',
        status: '已发布',
        logo: {
            color: '#9731ff',
        },
    },
])
const toApp = (app: AppVO) => {
    console.log(app)
}
</script>

<style scoped lang="scss">
.my-app {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 96px;
    gap: 15px;
    .item {
        border: 1px solid var(--border-color-light);
        border-radius: 8px;
        padding: 20px 16px 20px 16px;
        position: relative;
        cursor: pointer;
        display: flex;
        align-items: center;

        .left {
            width: 35px;
            height: 35px;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 8px;
            i {
                color: var(--color-white);
                font-size: 18px;
            }
            img {
                width: 18px;
                height: 18px;
            }
        }
        .right {
            margin-left: 8px;
            .title {
                height: 32px;
                line-height: 32px;
                max-width: 180px;
                white-space: nowrap; /* 不换行 */
                overflow: hidden; /* 隐藏超出部分 */
                text-overflow: ellipsis; /* 显示省略号 */
            }
            p {
                color: var(--text-color--gray);
                font-size: 12px;
            }
        }
        .status {
            position: absolute;
            top: 0;
            right: 0;
            border-radius: 0px 6px 0px 6px;
            width: 58px;
            height: 18px;
            line-height: 18px;
            font-size: 10px;
            color: var(--color-white);
            text-align: center;
            &.success {
                background: var(--color-success);
            }
            &.info {
                background: var(--color-info);
            }
        }
    }
    .item:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 16px 0 var(--background-color-primary-hover);
    }
}
</style>
